<?php
header("Content-type:text/html;charset=utf-8");
// error_reporting(0);
$db = new mysqli("localhost","root","","c1");
//错误编码
if($db->connect_errno){
	//输出错误信息
	exit($db->connect_error);
}
$db->query("set names utf8");
$result = $db->query("select title,nid from news");
$rows = array();
while($row= $result->fetch_assoc()){
	$rows[]=$row;
}

?>
	<table border="1" width="600">
			<tr>
			<?php
		while($fieldInfo = $result->fetch_field()):
			?>
			<td>
				<?php echo $fieldInfo->name?>
			</td>
			<?php
				endwhile;
			?>
		</tr>

			
		<?php 
			foreach($rows as $field):
		?>
			<tr>
				<td>
					<?php echo $field['nid'];?>
				</td>
				<td>
					<?php echo $field['title'];?>
				</td>
			</tr>
		<?php
			endforeach;
		?>
	</table>

<?php
echo "共有{$db->affected_rows}条";














?>